package com.neusoft.training.podcast.mapper;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.neusoft.training.podcast.entity.Favourite;

public interface FavouriteMapper {
	@Insert("insert into favourite(favouriteUserID, favouriteVedioID, favouriteTime) values (#{favouriteUserID},#{favouriteVedioID},#{favouriteTime})")
	void addFavourite(
			@Param("favouriteUserID") Integer favouriteUserID, 
			@Param("favouriteVedioID") String favouriteVedioID,
			@Param("favouriteTime") Timestamp favouriteTime);
	
	@Delete("delete from favourite where favouriteID=#{favouriteID}")
	void deleteFavourite(@Param("FavouriteID") Integer favouriteID);
	
	@Select("select * from favourite where favouriteUserID=#{favouriteUserID}")
	List<Favourite> findFavouriteByUser(@Param("favouriteUserID") Integer favouriteUserID);
	
	@Delete("delete from favourite where favouriteVedioID=#{favouriteVedioID}")
	void deleteFavouriteByVedioID(@Param("favouriteVedioID") String favouriteVedioID);
	
	@Select("select * from favourite where favouriteUserID=#{favouriteUserID} and favouriteVedioID=#{favouriteVedioID}")
	List<Favourite> findFavouriteByUserVideoID(@Param("favouriteUserID") Integer favouriteUserID, @Param("favouriteVedioID") String favouriteVedioID);
	
	@Select("select * from favourite where favouriteVedioID=#{favouriteVedioID}")
	List<Favourite> findFavouriteByVedioID(@Param("favouriteVedioID") String favouriteVedioID);

}

